<?php

Class m_klien extends CI_Model {

    function get_all_klien() {
        $this->db->order_by("id_klien", "DESC");
        $query = $this->db->get("klien");
        return $query->result();
    }

    function insert_klien($data) {
        return $this->db->insert('klien', $data);
    }

    function get_by_id($id_klien) {
        $query = $this->db->get_where('klien', array('id_klien' => $id_klien));
        return $query->row_array();
    }

    function update_klien($data, $id_klien) {
        $this->db->where('klien.id_klien', $id_klien);
        return $this->db->update('klien', $data);
    }

    function delete_klien($id_klien) {
        $this->db->where('klien.id_klien', $id_klien);
        return $this->db->delete('klien');
    }

    function get_all_list_area() {
        $this->db->select('*');
        $this->db->from('list_area');
        $this->db->order_by("id_list_area", "DESC");
        $this->db->join('klien', 'klien.id_klien = list_area.id_klien', 'left');

        $query = $this->db->get();
        return $query->result();
    }

    function get_list_area_by_id_klien($id_klien) {
        $this->db->select('*');
        $this->db->from('list_area');
        $this->db->where('list_area.id_klien', $id_klien);
        $this->db->join('klien', 'klien.id_klien = list_area.id_klien', 'left');

        $query = $this->db->get();
        return $query->result();
    }

    function insert_list_area($data) {
        return $this->db->insert('list_area', $data);
    }

    function get_list_area_by_id($id_list_area) {
        $query = $this->db->get_where('list_area', array('id_list_area' => $id_list_area));
        return $query->row_array();
    }

    function update_list_area($data, $id_list_area) {
        $this->db->where('list_area.id_list_area', $id_list_area);
        return $this->db->update('list_area', $data);
    }

    function delete_list_area($id_list_area) {
        $this->db->where('list_area.id_list_area', $id_list_area);
        return $this->db->delete('list_area');
    }

    function get_all_checklist() {
        $query = $this->db->get("pertanyaan");
        return $query->result();
    }

    function insert_checklist($data) {
        return $this->db->insert('pertanyaan', $data);
    }

    function get_checklist_by_id($id_pertanyaan) {
        $query = $this->db->get_where('pertanyaan', array('id_pertanyaan' => $id_pertanyaan));
        return $query->row_array();
    }

    function update_checklist($data, $id_pertanyaan) {
        $this->db->where('pertanyaan.id_pertanyaan', $id_pertanyaan);
        return $this->db->update('pertanyaan', $data);
    }

    function delete_checklist($id_pertanyaan) {
        $this->db->where('pertanyaan.id_pertanyaan', $id_pertanyaan);
        return $this->db->delete('pertanyaan');
    }

}